<extend name="Public/base" />

<block name="style" >
    <style>
        .user_table{
            border: 1px solid #ddd;
            width: 180px;
        }
        .user_table tr{
            border: 1px solid #dddddd;
            height: 30px;
        }
        .user_table td{
            border: 1px solid #dddddd;
            width: 90px;
            text-align: center;
        }
    </style>
</block>

<block name="body">
    <!-- 弹窗插件 -->
    <include file="Public:artdialog" />
    <!-- 表单验证插件 -->
    <include file="Public:validform" />

    <form action="{:U('addmessage')}" method="post" role="form" class="form-horizontal row-border vform" > 
        <input type="hidden" name="replyid" value="{$entity.replyid}" id="replyid"> 
        <div class="row">
            <div class="col-md-12">
                <div class="block-web">
                    <div class="header">
                        <h3 class="content-header">添加/修改</h3>
                    </div>
                    <div class="porlets-content"> 
                    
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><font class="red">*</font>类型</label>
                            <div class="col-sm-3">
                            <select name="replaytype" class="normal_select" id="mtype" field="{$entity.replaytype}">
								 <option value="0">图文</option>
								 <option value="1">文本</option>
							 </select> 
                            </div>
                        </div> 
                        
                         <div class="form-group">
                            <label class="col-sm-3 control-label"><font class="red">*</font>标题</label>
                            <div class="col-sm-3">
                                <input type="text" value="{$entity.title}" name="title"  class="form-control " datatype="*" nullmsg="请输入标题" />
                                <div class="Validform_checktip"></div>
                            </div>
                        </div> 
                        
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><font class="red">*</font>描述</label>
                            <div class="col-sm-3">
                            <textarea name="description" rows="8" cols="32"  class="form-control" >{$entity.description}</textarea>  
                            </div>
                        </div> 
                         <div class="form-group">
                            <label class="col-sm-3 control-label"><font class="red">*</font>图片</label>
                            <div class="col-sm-3">
                              <input multiple="multiple" type="file" name="picurl">  
                            </div>
                        </div> 
                        
                         <div class="form-group">
                            <label class="col-sm-3 control-label"><font class="red">*</font>链接地址</label>
                            <div class="col-sm-3">
                            <php>
                             $wxpath= C('WXConfigPathUrl');
                            </php>
                             <input type="text" class="input" name="url" value="{$entity.url}" autocomplete="off"  id="url_reid" field="{$wxpath}"/>
                             <select id="backrid"> 
                                        <option value="">外部链接</option>
                                        <volist name="wxmenu" id="o">
                                           <option value="{$o.url}">{$o.mname}</option>
                                        </volist>
	                                 </select>
                                   <p class="help-block pull-right">不为空，自定义访问当前地址.</p>
                            </div>
                        </div> 
                        
                         <div class="form-group">
                            <label class="col-sm-3 control-label"><font class="red">*</font>关键词</label>
                            <div class="col-sm-3">
                                <input type="text"  name="keyword" value="{$entity.keyword}"  placeholder="请输入关键词" class="form-control" datatype="*" nullmsg="请输入关键词" />
                                <div class="Validform_checktip"></div>
                            </div>
                        </div>   
                        <div class="form-group" >
                            <label class="col-sm-3 control-label"><font class="red">*</font>是否有效</label>
                            <div class="col-sm-6">
                                <label class="radio-inline">
                                    <input type="radio"  name="status" value="1"  {$entity['status']==1?'checked':''}>
                                    <span class="custom-radio"></span> 有效
                                </label>
                                <label class="radio-inline">
                                    <input type="radio"    name="status" value="0"  {$entity['status']==0?'checked':''}>
                                    <span class="custom-radio"></span> 无效
                                </label>
                            </div>
                        </div> 
                        <div class="form-group">
                            <label class="col-sm-3 control-label"></label>
                            <button class="btn btn-primary btn-success bt_submit" type="submit" id="submit">提交</button>
                        </div>
                    </div><!--/porlets-content-->
                </div><!--/block-web-->
            </div> 
        </div> 
    </form> 

</block>
<block name="script">
 <script type="text/javascript">
   $(function(){
	   $("#backrid").bind("change",function(){
		    var _url=$(this).val();
		    $("#url_reid").val(_url);
		});
	   
	   var _id=$("#replyid").val();
	   if(_id){
		   setTimeout(function(){init();},300)
	   }
   })
   
   var init=function(){
	   $("#mtype").val($("#mtype").attr("field")); 
	   var picurl=$('input[name="picurl"]').val();
	   if (picurl) { 
		 $('input[name="picurl"]').parent().append('<img src="__PUBLIC__/Uploads/'+json.image+'" id="goodimage" style="max-width:450px" class="img-thumbnail">'); 
		} 
	   
	   //处理url设置
	    var wxconfigpath=$("#url_reid").attr("field");
	    var thedomain= location.protocol+"//"+location.host + wxconfigpath;
	    var url=$("#url_reid").val();	    	
		url= url.replace(thedomain,"");
		if(url.indexOf("http://")!=-1)url="";
	    $("#backrid").val(url);
   }
   
   /*
        function searchUser(obj) { 
            var $username = $(obj).val();

            $.ajax({
                'url': "/indexadmin.php/Payment/search_user",
                'data': {username:$username},
                'dataType': 'json',
                'type': 'POST',
                success: function (data) {
                    if (data.status == 1) {
                        $('#user_info').show();
                        $("#nickname").html(data.a);
                        $("#mobile_phone").html(data.b);
                        $("#user_money").html(data.c);

                        $("#mobile").val(data.b);
                        $("#user_id").val(data.e);

                    }

                }, error: function (err) { 

                },complete: function () {

                }
            }); 
        }
   
   */ 

  </script>

</block>
